package com.aisile.admin.controller.v1;

import com.aisile.admin.service.AdChannelService;
import com.aisile.apis.admin.AdChannelControllerApi;
import com.aisile.model.admin.dtos.ChannelDto;
import com.aisile.model.admin.pojos.AdChannel;
import com.aisile.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.ws.rs.POST;

/**
 * @Auther:yry
 * @Date:2024/4/22 0022
 * @VERSON:1.0
 */
@RestController
@RequestMapping("/ad_channel")
public class AdChannelController implements AdChannelControllerApi {

    @Autowired
    private AdChannelService adChannelService;

    @PostMapping("/list")
    @Override
    public ResponseResult findListByPage(@RequestBody ChannelDto dto) {
        return adChannelService.findListByPage(dto);
    }

    @PostMapping("/save")
    @Override
    public ResponseResult saveAdChannel(@RequestBody AdChannel adChannel) {
        return adChannelService.saveAdChannel(adChannel);
    }

    @PutMapping("/update/{id}")
    @Override
    public ResponseResult updateAdChannel(@PathVariable("id") Integer id,@RequestBody AdChannel adChannel) {
        return adChannelService.updateAdChannel(id,adChannel);
    }

    @PutMapping("/avail/{id}")
    @Override
    public ResponseResult updateStatusTrueById(@PathVariable("id") Integer id) {
        // 先写好中文注释  固定方式实现状态修改，在service中使用0和1进行修改即可
        return adChannelService.updateCahnnelStatusById(id,0);
    }

    @PutMapping("/no_avail/{id}")
    @Override
    public ResponseResult updateStatusFalseById(@PathVariable("id") Integer id) {
        return adChannelService.updateCahnnelStatusById(id,1);
    }
}
